home *** CD-ROM | disk | FTP | other *** search
/ Aminet 15 / Aminet 15 - Nov 1996.iso / Aminet / dev / c / EasygadgetsSou.lha / EasyGadgets / Windows.c < prev   
C/C++ Source or Header  |  1995-11-13  |  4KB  |  184 lines

  1. /*
  2.  *    File:                    
  3.  *    Description:    
  4.  *
  5.  *    (C) 1994,1995 Ketil Hunn
  6.  *
  7.  */
  8.  
  9. #ifndef EG_WINDOWS_H
  10. #define EG_WINDOWS_H
  11.  
  12. /*** DEFINES *************************************************************************/
  13. #define    EG_EGWINDOW    ~0
  14.  
  15. /*** GLOBALS *************************************************************************/
  16. UWORD __chip EG_waitPointer[] =
  17. {
  18.     0x0000,    0x0000,
  19.     0x0400, 0x07C0,
  20.     0x0000, 0x07C0,
  21.     0x0100, 0x0380,
  22.     0x0000, 0x07E0,
  23.     0x07C0, 0x1FF8,
  24.     0x1FF0, 0x3FEC,
  25.     0x3FF8, 0x7FDE,
  26.     0x3FF8, 0x7FBE,
  27.     0x7FFC, 0xFF7F,
  28.     0x7EFC, 0xFFFF,
  29.     0x7FFC, 0xFFFF,
  30.     0x3FF8, 0x7FFE,
  31.     0x3FF8, 0x7FFE,
  32.     0x1FF0, 0x3FFC,
  33.     0x07C0, 0x1FF8,
  34.     0x0000, 0x07E0,
  35.     0x0000, 0x0000
  36. };
  37.  
  38. /*** FUNCTIONS ***********************************************************************/
  39. __asm __saveds int egCountVisitors(register __a0 struct Screen *screen)
  40. {
  41.     register int n=0;
  42.     register struct Window    *window;
  43.     ULONG IntuiLock=LockIBase(0);
  44.  
  45. #ifdef MYDEBUG_H
  46.     DebugOut("egCountVisitors");
  47. #endif
  48.  
  49.     for(window=screen->FirstWindow; window!=NULL; window=window->NextWindow)
  50.     {
  51.         if(window->UserData!=(APTR)EG_EGWINDOW)
  52.             ++n;
  53.         n-=window->ReqCount;
  54.     }
  55.     UnlockIBase(IntuiLock);
  56.     return n;
  57. }
  58.  
  59. __asm __saveds ULONG egIsDisplay(    register __a0 struct Screen *screen,
  60.                                                                     register __d0 ULONG is_property)
  61. {
  62.     DisplayInfoHandle handle=FindDisplayInfo(GetVPModeID(&(screen->ViewPort)));
  63.  
  64. #ifdef MYDEBUG_H
  65.     DebugOut("egIsDisplay");
  66. #endif
  67.  
  68.     if(handle)
  69.     {
  70.         struct DisplayInfo    di;
  71.  
  72.         GetDisplayInfoData(handle, (UBYTE *)&di, sizeof(di), DTAG_DISP, NULL);
  73.         if(di.PropertyFlags)
  74.             return (di.PropertyFlags & is_property);
  75.         else
  76.             return 0L;
  77.     }
  78. }
  79.  
  80. __asm __saveds void egGhostRect(register __a0 struct RastPort    *rp,
  81.                                                                 register __d0    SHORT                        x,
  82.                                                                 register __d1 SHORT                     y,
  83.                                                                 register __d2 SHORT                     w,
  84.                                                                 register __d3 SHORT                     h,
  85.                                                                 register __d4 UBYTE                        pen)
  86. {
  87.     register USHORT patterndata[2];
  88.  
  89.     patterndata[0]=0x2222; patterndata[1]=0x8888;
  90.     SetDrMd(rp, JAM1);
  91.     SetAPen(rp, pen);
  92.     SetAfPt(rp, patterndata, 1);
  93.     RectFill(rp,    x, y, w, h);
  94.     SetAfPt(rp, NULL, 0);
  95. }
  96.  
  97. __asm __saveds BYTE egLockTaskA(register __a0 struct egTask        *task,
  98.                                                                 register __a1 struct TagItem    *taglist)
  99. {
  100. #ifdef MYDEBUG_H
  101.     DebugOut("egLockTask");
  102. #endif
  103.  
  104.     
  105.     if(task && ++task->reqcount && task->lock==NULL)
  106.     {
  107.         if(task->lock=AllocVec(sizeof(struct Requester), 0))
  108.         {
  109.             InitRequester(task->lock);
  110.             Request(task->lock, task->window);
  111.  
  112.             if(IntuitionBase->LibNode.lib_Version>=39)
  113.                 SetWindowPointer( task->window,
  114.                                                     WA_BusyPointer, TRUE,
  115.                                                     WA_PointerDelay,TRUE,
  116.                                                     TAG_END);
  117.             else
  118.                 SetPointer(task->window, EG_waitPointer, 16, 16, -6, 0);
  119.  
  120.             if(task->status && ISBITSET(task->flags, TASK_GHOSTWHENBLOCKED))
  121.                 egGhostRect(task->window->RPort,
  122.                                         task->window->BorderLeft,    task->window->BorderTop,
  123.                                         task->window->Width-task->window->BorderRight-1,
  124.                                         task->window->Height-task->window->BorderBottom-1,
  125.                                         1);
  126.             SETBIT(task->flags, TASK_BLOCKED);
  127.         }
  128.     }
  129.     return FALSE;
  130. }
  131.  
  132. __asm __saveds void egUnlockTaskA(register __a0 struct egTask *task,
  133.                                                                     register __a1 struct TagItem *taglist)
  134. {
  135. #ifdef MYDEBUG_H
  136.     DebugOut("UnlockTask");
  137. #endif
  138.  
  139.     if(task && task->lock && 0==(task->reqcount=MAX(0, task->reqcount-1)))
  140.     {
  141.         if(ISBITSET(task->flags, TASK_GHOSTWHENBLOCKED))
  142.         {
  143.             egGhostRect(task->window->RPort,
  144.                                 task->window->BorderLeft,    task->window->BorderTop,
  145.                                 task->window->Width-task->window->BorderRight-1,
  146.                                 task->window->Height-task->window->BorderBottom-1,
  147.                                 0);
  148.             RefreshGList(task->glist, task->window, NULL, -1);
  149.             GT_RefreshWindow(task->window, NULL);
  150.         }
  151.  
  152.         EndRequest(task->lock, task->window);
  153.         FreeVec(task->lock);
  154.         task->lock=NULL;
  155.  
  156.         if(IntuitionBase->LibNode.lib_Version>=39)
  157.             SetWindowPointer(task->window, TAG_END);
  158.         else
  159.             ClearPointer(task->window);
  160.  
  161.         CLEARBIT(task->flags, TASK_BLOCKED);
  162.     }
  163. }
  164.  
  165. __asm __saveds void egLockAllTasks(register __a0 struct EasyGadgets *eg)
  166. {
  167.     register struct egTask    *task;
  168.  
  169.     for(task=eg->tasklist; task; task=task->nexttask)
  170.         if(task->status==STATUS_OPEN)
  171.             egLockTaskA(task, NULL);
  172. }
  173.  
  174. __asm __saveds void egUnlockAllTasks(register __a0 struct EasyGadgets *eg)
  175. {
  176.     register struct egTask    *task;
  177.  
  178.     for(task=eg->tasklist; task; task=task->nexttask)
  179.         if(task->status==STATUS_OPEN)
  180.             egUnlockTaskA(task, NULL);
  181. }
  182.  
  183. #endif
  184.